<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>选择服务-去保养-氦修驿站旗下品牌无忧</title>
    <meta name="keywords" content="汽车保养,汽车配件,汽车维修,养车无忧,养车,4S店品质,氦修驿站,丰田保养" />
    <meta name="description" content="100%正品配件,4S店一半价格,先行赔付,闪电送达!线上购买配件,线下提供安装.上万用户的最佳选择!去掉中间环节,直接从源头采购配件!" />
	<link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/css/base.css">
    <link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/css/baoyang.css">
    <script type="text/javascript" src="{:C('WEB_URL')}Public/js/jquery.11.js"></script>
</head>
<body>

    <include file="Public:header" />

    <div id="wrap">
        <img src="{:C('WEB_URL')}Public/images/gg.png" style="margin-bottom:20px;">
        <div class="title">
            <h2>预约保养</h2>
            <p class="step">
                <em>1、选择车型</em><i>&#xe606;</i>
                <em class="current">2、选择服务</em><i>&#xe606;</i>
                <em>3、选择维修厂</em><i>&#xe606;</i>
                <em>4、确认信息</em>
            </p>
        </div>
        
        <div class="server">
            <div class="autoInfo">
                <div class="serverName">
                    保养项目：<em>小保养（机油+机滤）</em>
                </div>
                <img src="/{$auto['brand_logo']}" class="autoLogo">
                <p>
                    您的爱车：
                    <span class="brand_name">{$auto['brand_name']} {$auto['model_name']} {$auto['model_pl']} {$auto['model_year']} </span>
                    <a href="{:U('index')}" class="ml10">修改</a>
                </p>
                <p>所需机油量：<span id="J_valueJY">{$auto['capacity']}</span>L</p>
            </div>
            <div class="recommend" id="J_recommend">
                <h3>推荐保养品 <span><i></i> 78%的用户选择</span></h3>
                <div class="txt">
                    <i class="hide">&#xe60c;</i>
                    <p>推荐理由：为了更好的保护您爱车的发动机，我们推荐您使用下列保养产品</p>
                </div>
                <div class="itemList">
                    <ul>
                        <li>
                            <em>机油：</em>
                            <div class="select">
                                <div class="selected">
                                    <img src="http://app2.haixiuyizhan.com/{$jiyouRec4['logo']}" alt="">
                                    <p class="name">{$jiyouRec4['pj_name']} {$jiyouRec4['weight']}L*1</p>
                                    <p class="desc">{$jiyouRec4['content']}</p>
                                    <p class="price">￥{$jiyouRec4['pj_csprice']}</p>
                                    <input type="hidden" value="{$jiyouRec4['pj_id']}" class="J_jyId"/>
                                </div>
                            </div>
                        </li>
                        <li>
                            <em>机滤：</em>
                            <div class="select">
                                <div class="selected">
                                    <img src="http://app2.haixiuyizhan.com/{$jilv[0]['logo']}" alt="">
                                    <p class="name">{$jilv[0]['pj_pinpai']} {$jilv[0]['pj_xinghao']}</p>
                                    <p class="desc">{$jilv[0]['content']}</p>
                                    <p class="price">￥{$jilv[0]['pj_csprice']}</p>
                                    <input type="hidden" value="{$jilv[0]['pj_id']}" class="J_jvId"/>
                                </div>
                            </div>
                        </li>
                    </ul>

                </div>
                <div class="other">
                    <gt name="auto['capacity']" value="4">
                    <p class="other">您的爱车排量较高，还需要额外增加{$auto['capacity']-4}L机油</p>
                    </gt>
                    <if condition="($auto['capacity']-4) egt 4">
                        <div class="otherMain">
                            <img src="http://app2.haixiuyizhan.com/{$jiyouRec4['logo']}" alt="">
                            <p class="price">￥{$jiyouRec4['pj_csprice']*floor(($auto['capacity']-4)/4)}</p>
                            <p class="name">{$jiyouRec4['pj_name']} {$jiyouRec4['weight']}L*<php>echo floor(($auto['capacity']-4)/4);</php></p>
                            <p class="desc">{$jiyouRec4['content']}</p>
                        </div>
                    </if>
                    <if condition="($auto['capacity']%4) gt 0">
                        <div class="otherMain">
                            <img src="http://app2.haixiuyizhan.com/{$jiyouRec1['logo']}" alt="">
                            <p class="price">￥{$jiyouRec1['pj_csprice']*($auto['capacity']%4)}</p>
                            <p class="name">{$jiyouRec1['pj_name']} {$jiyouRec1['weight']}L*{$auto['capacity']%4}</p>
                            <p class="desc">{$jiyouRec1['content']}</p>
                        </div>
                    </if>
                </div>
                <i class="selected"></i>
            </div>

            <div class="default current" id="J_default">
                <h3>去保养普通套餐</h3>
                <div class="itemList">
                    <div class="nineNine">
                        <ul>
                            <li>
                                <em>机油：</em>
                                <div class="select">
                                    <div class="selected">
                                        <img src="http://app2.haixiuyizhan.com/{$jiyouDef4['logo']}" alt="">
                                        <p class="name">{$jiyouDef4['pj_name']} {$jiyouDef4['weight']}L*1<a href="javascript:void(0)" onclick="chooseGoods.showList('#J_goodsListJY')">修改</a></p>
                                        <p class="desc">{$jiyouDef4['content']}</p>
                                        <p class="price">￥{$jiyouDef4['pj_csprice']}</p>
                                        <input type="hidden" value="{$jiyouDef4['pj_id']}" class="J_jyId"/>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <em>机滤：</em>
                                <div class="select">
                                    <div class="selected">
                                        <img src="http://app2.haixiuyizhan.com/{$jilv[0]['logo']}" alt="">
                                        <p class="name">{$jilv[0]['pj_pinpai']} {$jilv[0]['pj_xinghao']}<a href="javascript:void(0)"  onclick="chooseGoods.showList('#J_goodsListJV')">修改</a></p>
                                        <p class="desc">{$jilv[0]['content']}</p>
                                        <p class="price">￥{$jilv[0]['pj_csprice']}</p>
                                        <input type="hidden" value="{$jilv[0]['pj_id']}" class="J_jvId"/>
                                    </div>
                                </div>
                            </li>
                        </ul>
                        <p class="subtotal">
                            <span>￥{$jilv[0]['pj_csprice']+$jiyouDef4['pj_csprice']}</span>
                        </p>
                    </div>
                    <div class="other">
                        <gt name="auto['capacity']" value="4">
                        <p class="other">您的爱车排量较高，需要额外增加{$auto['capacity']-4}L机油</p>
                        </gt>
                        <if condition="($auto['capacity']-4) egt 4">
                            <div class="otherMain">
                                <img src="http://app2.haixiuyizhan.com/{$jiyouDef4['logo']}" alt="">
                                <p class="price">￥{$jiyouDef4['pj_csprice']*floor(($auto['capacity']-4)/4)}</p>
                                <p class="name">{$jiyouDef4['pj_name']} {$jiyouDef4['weight']}L*<php>echo floor(($auto['capacity']-4)/4);</php></p>
                                <p class="desc">{$jiyouDef4['content']}</p>
                            </div>
                        </if>
                        <if condition="($auto['capacity']%4) gt 0">
                            <div class="otherMain">
                                <img src="http://app2.haixiuyizhan.com/{$jiyouDef1['logo']}" alt="">
                                <p class="price">￥{$jiyouDef1['pj_csprice']*($auto['capacity']%4)}</p>
                                <p class="name">{$jiyouDef1['pj_name']} {$jiyouDef1['weight']}L*{$auto['capacity']%4}</p>
                                <p class="desc">{$jiyouDef1['content']}</p>
                            </div>
                        </if>
                        
                    </div>
                    <i class="selected"></i>
                </div>
               
            </div>
            <p align="center" class="clearfix total">
                <em>总计：</em> <span id="J_totalPrice">￥299</span>
                <a href="javascript:void(0)" class="btnOrange" id="J_nextStep">下一步</a>
            </p>
        </div>
    </div>


    <div class="dialog goodsList" id="J_goodsListJY">
        <div class="dialog-content">
            <div class="dialog-tit clearfix">
                <strong>选择机油</strong>
                <a href="javascript:void(0)" class="close error-icon">×</a>
            </div>
            <div class="content">
                <ul>
                    <volist name="jiyou4" id="vo">
                    <li onclick="chooseGoods.chooseJY({$vo['pj_id']},this)" <eq name="vo['pj_id']" value="$jiyouDef4['pj_id']"> class="current" </eq>>
                        <img src="http://app2.haixiuyizhan.com/{$vo['logo']}" />
                        <p class="name">{$vo['pj_name']}</p>
                        <p class="price">￥{$vo['pj_csprice']}</p>
                        <i>&#xe60d;</i>
                    </li>
                    </volist>
                </ul>
            </div>
        </div>
    </div>
    <div class="dialog goodsList" id="J_goodsListJV">
        <div class="dialog-content">
            <div class="dialog-tit clearfix">
                <strong>选择机滤</strong>
                <a href="javascript:void(0)" class="close error-icon">×</a>
            </div>
            <div class="content">
                <ul>
                    <volist name="jilv" id="vo">
                    <li onclick="chooseGoods.chooseJV({$vo['pj_id']},this)" <eq name="i" value="1"> class="current" </eq>>
                        <img src="http://app2.haixiuyizhan.com/{$vo['logo']}">
                        <p class="name">{$vo['pj_pinpai']} {$vo['pj_xinghao']}</p>
                        <p class="desc hide">{$vo['content']}</p>
                        <p class="price">￥{$vo['pj_csprice']}</p>
                        <i>&#xe60d;</i>
                    </li>
                    </volist>
                </ul>
            </div>
        </div>
    </div>

    <include file="Public:footer" />
    <include file="Public:loginReg" />
    <script type="text/javascript" src="{:C('WEB_URL')}Public/js/common.js"></script>
    <script type="text/javascript" src="{:C('WEB_URL')}Public/js/precontract.js"></script>
    <script type="text/javascript" src="{:C('WEB_URL')}Public/js/My97DatePicker/WdatePicker.js"></script>
    <script>
    $(".dialog").find(".close").on("click",function(){
        $(this).parents(".dialog").hide();
    })
    var chooseGoods={
        choose:"J_default",
        init:function(){
            var _t=this;
            $("#J_totalPrice").html("￥"+this.getDefaultPrice());

            $("#J_default").on("click",function(){
                $(this).addClass("current");
                $("#J_recommend").removeClass("current");
                $("#J_totalPrice").html("￥"+_t.getDefaultPrice());
                _t.choose="J_default";
            })

            $("#J_recommend").on("click",function(){
                $(this).addClass("current");
                $("#J_default").removeClass("current");
                var total=0;
                $(this).find(".price").each(function(e){
                    total+=$(this).html().replace(/\D/g,"")*1;
                })
                $("#J_totalPrice").html("￥"+total);
                _t.choose="J_recommend";
            })

            $("#J_nextStep").on("click",function(){
                var jyId=$("#"+_t.choose).find(".J_jyId").val(),
                    jvId=$("#"+_t.choose).find(".J_jvId").val();
                    
                window.location.href="/baoyang/step3/val/"+jyId+","+jvId;
            })
        },
        showList:function(str){
            $(str).show();
        },

        //获取99套餐总价
        getDefaultPrice:function(){
            var total=0;
            total=$("#J_default").find(".subtotal").html().replace(/\D/g,"")*1;
            $("#J_default").find("div.other").find(".price").each(function(){
                total+=$(this).html().replace(/\D/g,"")*1;
            })
            return total;
        },
        //选择机油
        chooseJY:function(id,t){
            var _t=this;
            $(t).addClass("current").siblings("li").removeClass("current");
            $("#J_goodsListJY").hide();
            $.ajax({
                type:"post",
                url:"{:U('chooseJY')}",
                data:{"pj_id":id},
                dataType:"json",
                success:function(res){
                    if(res.status==1){
                        _t.printJY(res.data);
                    }else{
                        alert(res.info)
                    }
                }

            })
        },
        //输出选择后的机油数据
        printJY:function(data){
            if(data['four']['pj_id']==data['one']['pj_id']){
                //返回数据都为1升数据时（推荐全部以1升装出售）
                var htmlFour='<img src="http://app2.haixiuyizhan.com/'+data['four']['logo']+'" alt="">'+
                        '<p class="name">'+data['four']['pj_name']+" "+data['four']['weight']+'L*4<a href="javascript:void(0)" onclick="chooseGoods.showList(\'#J_goodsListJY\')">修改</a></p>'+
                        '<p class="desc">'+data['four']['content']+'</p>'+
                        '<p class="price">￥'+(data['four']['pj_csprice']*4)+'</p>'+
                        '<input type="hidden" value="'+data['four']['pj_id']+'" class="J_jyId"/>';
            }else{
                var htmlFour='<img src="http://app2.haixiuyizhan.com/'+data['four']['logo']+'" alt="">'+
                        '<p class="name">'+data['four']['pj_name']+" "+data['four']['weight']+'L*1<a href="javascript:void(0)" onclick="chooseGoods.showList(\'#J_goodsListJY\')">修改</a></p>'+
                        '<p class="desc">'+data['four']['content']+'</p>'+
                        '<p class="price">￥'+data['four']['pj_csprice']+'</p>'+
                        '<input type="hidden" value="'+data['four']['pj_id']+'" class="J_jyId"/>';
            }

            var select=$("#J_default").find("div.selected"),
                valueJY=$("#J_valueJY").html(),
                htmlOther="<p class='other'>"+$("p.other").html()+"</p>";   //额外机油量

            select.eq(0).html(htmlFour);

            if(data['nine']){   //是否为套餐默认机油
                $(".subtotal").children("span").html("￥299");
            }else if(data['four']['pj_id']==data['one']['pj_id']){  //主推1升装的机油
                var subtotal=data['four']['pj_csprice']*4+select.eq(1).find(".price").html().replace(/\D/g,"")*1;
                $(".subtotal").children("span").html("￥"+subtotal);
            }else{
                var subtotal=data['four']['pj_csprice']*1+select.eq(1).find(".price").html().replace(/\D/g,"")*1;
                $(".subtotal").children("span").html("￥"+subtotal);
            }

            var f=Math.floor((valueJY-4)/4),    //附件4升量
                o=(valueJY-4)%4;    //附件1升量
            if(f>0){
                htmlOther+='<div class="otherMain">'+
                                '<img src="http://app2.haixiuyizhan.com/'+data['four']['logo']+'" alt="">'+
                                '<p class="price">￥'+data['four']['pj_csprice']*f+'</p>'+
                                '<p class="name">'+data['four']['pj_name']+" "+data['four']['weight']+'L*'+f+'</p>'+
                                '<p class="desc">'+data['four']['content']+'</p>'+
                            '</div>';
            }

            if(o!=0){
                htmlOther+='<div class="otherMain">'+
                                '<img src="http://app2.haixiuyizhan.com/'+data['one']['logo']+'" alt="">'+
                                '<p class="price">￥'+data['one']['pj_csprice']*o+'</p>'+
                                '<p class="name">'+data['one']['pj_name']+" "+data['one']['weight']+'L*'+o+'</p>'+
                                '<p class="desc">'+data['one']['content']+'</p>'+
                            '</div>';
            }
            $("#J_default").find("div.other").html(htmlOther);
            $("#J_totalPrice").html("￥"+this.getDefaultPrice());
        },
        //选择机滤
        chooseJV:function(id,t){
            $(t).addClass("current").siblings("li").removeClass("current");
            $("#J_goodsListJV").hide();

            var tt=$(t).clone();
            tt.find("i").remove();
            tt.find(".desc").show();
            tt.find(".name").append('<a href="javascript:void(0)" onclick="chooseGoods.showList(\'#J_goodsListJV\')">修改</a>');

            

            var html=tt.html(),
                select=$("#J_default").find("div.selected"),
                total=0,
                index=$(t).index();

            select.eq(1).html(html).append('<input type="hidden" value="'+id+'" class="J_jvId"/>');

            if(index==0){
                total=299;
            }else{
                select.each(function(){
                    total+=$(this).find(".price").html().replace(/\D/g,"")*1;
                })

            }
            
            $("#J_default").find(".subtotal").children("span").html("￥"+total);

            
            $("#J_totalPrice").html("￥"+this.getDefaultPrice());
        }
    }
    chooseGoods.init();
    </script>

</body>
</html>